<!DOCTYPE html>
<html lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="古 文">



<meta name="description" content="一、简介 ​       要移植gstreamer到qnx系统，除了本身的libgstreamer之外，还需要编译相关的插件库，比如编解码库，比如各种音视频容器库。">
<meta name="keywords" content="插件,多媒体,gstreamer,qnx,移植">
<meta property="og:type" content="article">
<meta property="og:title" content="gstreamer移植qnx(四)：编译gstreamer插件">
<meta property="og:url" content="http://xuanwolanxue.gitee.io/posts/28659.html">
<meta property="og:site_name" content="同好斋">
<meta property="og:description" content="一、简介 ​       要移植gstreamer到qnx系统，除了本身的libgstreamer之外，还需要编译相关的插件库，比如编解码库，比如各种音视频容器库。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-02-20T13:01:09.878Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="gstreamer移植qnx(四)：编译gstreamer插件">
<meta name="twitter:description" content="一、简介 ​       要移植gstreamer到qnx系统，除了本身的libgstreamer之外，还需要编译相关的插件库，比如编解码库，比如各种音视频容器库。">

<link rel="apple-touch-icon" href="/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="同好斋" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>gstreamer移植qnx(四)：编译gstreamer插件 | 同好斋</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?778ff23279d4dd12f6287e98750f2d86";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head></html>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/Minions.jpeg" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">古 文</a></h1>
        </hgroup>

        
        <p class="header-subtitle">同好斋</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="">
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class="no-result">No results found <i class="fa fa-spinner fa-pulse"></i></p>
        


        
		
        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
					<br>
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/categories/">分类</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/download/">下载</a></li>
                        
                            <li><a href="/tags/">标签</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <br>
                    <br>
                    <br>
                    <br>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">喜欢软件，爱好硬件的嵌入式工程师</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">古 文</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/Minions.jpeg" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">古 文</a></h1>
            </hgroup>
            
            <p class="header-subtitle">同好斋</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/categories/">分类</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/download/">下载</a></li>
                
                    <li><a href="/tags/">标签</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:454727014@qq.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" target="_blank" href="https://weibo.com/u/2135682705" title="新浪微博"></a>
                            
                                <a class="fa CSDN" target="_blank" href="https://blog.csdn.net/xuanwolanxue" title="CSDN"></a>
                            
                                <a class="fa 微信" target="_blank" href="/img/微信.jpg" title="微信"></a>
                            
                                <a class="fa 码云" target="_blank" href="https://gitee.com/xuanwolanxue" title="码云"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我">
</nav>
      <div class="body-wrap"><article id="post-多媒体_gstreamer移植qnx(4)编译qnx版本的gstreamer插件库" class="article article-type-post" itemscope="" itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/posts/28659.html" class="article-date">
      <time datetime="2020-02-20T07:10:12.978Z" itemprop="datePublished">2020-02-20</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      gstreamer移植qnx(四)：编译gstreamer插件
    </h1>
  

        
			<div style="margin-top:10px;">
    <span class="post-time">
      <span class="post-meta-item-icon">
        <i class="fa fa-keyboard-o"></i>
        <span class="post-meta-item-text">  字数统计: </span>
        <span class="post-count">3.7k 字</span>
      </span>
    </span>

    <span class="post-time">
      &nbsp; | &nbsp;
      <span class="post-meta-item-icon">
        <i class="fa fa-hourglass-half"></i>
        <span class="post-meta-item-text">  阅读时长: </span>
        <span class="post-count">18 分</span>
      </span>
    </span>

    
        <span id="busuanzi_container_page_pv">
          &nbsp; | &nbsp;  本文总阅读量: <span id="busuanzi_value_page_pv"></span> 次
        </span>
    
</div>

        
      </header>
      
      <div class="article-info article-info-post">
        
          <br>
          <br>
        
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/多媒体系列/">多媒体系列</a><a class="article-category-link" href="/categories/多媒体系列/gstreamer移植qnx/">gstreamer移植qnx</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/gstreamer/">gstreamer</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/qnx/">qnx</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/多媒体/">多媒体</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/插件/">插件</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/移植/">移植</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1>一、简介</h1>
<p>​       要移植gstreamer到qnx系统，除了本身的libgstreamer之外，还需要编译相关的插件库，比如编解码库，比如各种音视频容器库。</p>
<a id="more"></a> 
<h1>二、 编译plugin base 库</h1>
<p>​        这里笔者一开始使用的和libgstreamer库一样，使用configure的方式，写一个myconfig.sh来编译，但是发现编译出来的plugin library会带有rpath的硬依赖路径，因此这里尝试了另一种方式， 和编译glib一样，使用meson交叉编译，写一个qnx_arm.txt的 cross file文件，其内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">[host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line">pkgconfig  = 'pkg-config'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lffi']</span><br><span class="line">cpp_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">cpp_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lffi']</span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<p>​          除了cross file文件之外，还需要修改 meson.build文件，其修改部分如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">default_options : [ 'warning_level=1',</span><br><span class="line">                   'buildtype=release', # 修改编译类型为release </span><br><span class="line">                   'gtk_doc=disabled',  # 禁用gtk_doc </span><br><span class="line">                   'alsa=disabled',     # 禁用alsa </span><br><span class="line">                   'x11=disabled',      # 禁用x11 </span><br><span class="line">                   'pango=disabled',    # 禁用pango </span><br><span class="line">                   'orc=disabled'       # 禁用orc </span><br><span class="line">                  ])</span><br></pre></td></tr></table></figure>
<p>​        另外，还需要设置pkg config 的路径：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export PKG_CONFIG_LIBDIR=/media/guwen/workspace/project/gstreamer/out/lib/pkgconfig</span><br></pre></td></tr></table></figure>
<blockquote>
<p><font color="red">注：</font> 若果设置成了</p>
<p>export PKG_CONFIG_PATH=/media/guwen/workspace/project/gstreamer/out/lib/pkgconfig</p>
<p>就必须要在再设置PKG_CONFIG_LIBDIR， 因为如果只设置了PKG_CONFIG_PATH路径， pkg-config在这个路径搜索之后，再到PKG_CONFIG_LIBDIR(这个就会是寄主系统默认路径，Ubuntu的/usr/lib/pkgconfig等等)这个路径搜索， 因此一定要设置PKG_CONFIG_LIBDIR变量，以防止pkg-config到系统默认路径去搜索。</p>
</blockquote>
<p>接下来也就是配置，编译，安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">mkdir build</span><br><span class="line">cd build</span><br><span class="line">meson .. --cross-file ../qnx_arm.txt</span><br><span class="line">ninja</span><br><span class="line">ninja install</span><br></pre></td></tr></table></figure>
<h1>三、编译plugin good 库</h1>
<p>plugin good库也是使用meson进行编译的，首先是qnx_arm.txt这个cross file的编写，其内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">[host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line">pkgconfig  = 'pkg-config'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lglib-2.0', '-lintl',  '-lffi']</span><br><span class="line">cpp_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">cpp_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lglib-2.0', '-lintl', '-lffi']</span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<p>然后是meson.build修改：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">default_options : [ 'warning_level=1',</span><br><span class="line">                    'buildtype=release', #修改编译类型为release</span><br><span class="line">                    'c_std=gnu99',        #修改c语言标准为99标准</span><br><span class="line">                    'mpg123=enabled'      #使能mp3 audio decoder</span><br><span class="line">                  ])</span><br></pre></td></tr></table></figure>
<h1>3.1 编译mpg123</h1>
<p>​         首下载mpg123库源码 <a href="http://www.mpg123.de/download/mpg123-1.25.13.tar.bz2" target="_blank" rel="noopener">http://www.mpg123.de/download/mpg123-1.25.13.tar.bz2</a> ，这里使用的是最新的1.25.13版本。</p>
<p>​      mpg123使用的也是configure，make的方式。 因此为了方便，先编写myconfig.sh脚本文件，其内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./configure --prefix=/media/guwen/workspace/project/gstreamer/out --build=i686-linux --host=arm-unknown-nto-qnx6.6.0eabi</span><br></pre></td></tr></table></figure>
<p>​       接下来就是编译和安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="3-2-修改编译错误">3.2 修改编译错误</h2>
<ul>
<li>修改源文件gst/flx/gstflxdec.c</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始版本 882行 */</span></span><br><span class="line"><span class="keyword">if</span> (!flx_decode_chunks (flxdec, n_chunks, &amp;chunks, &amp;writer)) &#123;</span><br><span class="line">    GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,</span><br><span class="line">        (<span class="string">"%s"</span>, <span class="string">"Could not decode chunk"</span>), <span class="literal">NULL</span>);</span><br><span class="line">    <span class="keyword">goto</span> unmap_input_error;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (!flx_decode_chunks (flxdec, n_chunks, &amp;chunks, &amp;writer)) &#123;</span><br><span class="line">    GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,</span><br><span class="line">        (<span class="string">"%s"</span>, <span class="string">"Could not decode chunk"</span>), (<span class="literal">NULL</span>));</span><br><span class="line">    <span class="keyword">goto</span> unmap_input_error;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 894行 */</span></span><br><span class="line">out = gst_buffer_new_and_alloc (flxdec-&gt;size * <span class="number">4</span>);</span><br><span class="line"> <span class="keyword">if</span> (!gst_buffer_map (out, &amp;<span class="built_in">map</span>, GST_MAP_WRITE)) &#123;</span><br><span class="line">   GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,</span><br><span class="line">       (<span class="string">"%s"</span>, <span class="string">"Could not map output buffer"</span>), <span class="literal">NULL</span>);</span><br><span class="line">   gst_buffer_unref (out);</span><br><span class="line">   <span class="keyword">goto</span> unmap_input_error;</span><br><span class="line"> &#125;</span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line">out = gst_buffer_new_and_alloc (flxdec-&gt;size * <span class="number">4</span>);</span><br><span class="line"> <span class="keyword">if</span> (!gst_buffer_map (out, &amp;<span class="built_in">map</span>, GST_MAP_WRITE)) &#123;</span><br><span class="line">   GST_ELEMENT_ERROR (flxdec, STREAM, DECODE,</span><br><span class="line">       (<span class="string">"%s"</span>, <span class="string">"Could not map output buffer"</span>), (<span class="literal">NULL</span>));</span><br><span class="line">   gst_buffer_unref (out);</span><br><span class="line">   <span class="keyword">goto</span> unmap_input_error;</span><br><span class="line"> &#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>修改文件 gst/multifile/gstsplitmuxsink.c</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始版本 1564行 */</span></span><br><span class="line">GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,</span><br><span class="line">      (<span class="string">"Could not create the new muxer/sink"</span>), <span class="literal">NULL</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line">GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,</span><br><span class="line">      (<span class="string">"Could not create the new muxer/sink"</span>), (<span class="literal">NULL</span>));</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 1753行 */</span></span><br><span class="line">GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,</span><br><span class="line">       (<span class="string">"Could not create the new muxer/sink"</span>), <span class="literal">NULL</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line">GST_ELEMENT_ERROR (splitmux, RESOURCE, SETTINGS,</span><br><span class="line">       (<span class="string">"Could not create the new muxer/sink"</span>), (<span class="literal">NULL</span>));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>修改文件gst/rtp/gstrtpj2kdepay.c</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始版本 211行 */</span></span><br><span class="line">GST_ELEMENT_WARNING (depayload, STREAM, DEMUX, <span class="literal">NULL</span>,</span><br><span class="line">     (<span class="string">"Non-compliant stream: sampling field missing. Frames my appear incorrect"</span>));</span><br><span class="line"></span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line">GST_ELEMENT_WARNING (depayload, STREAM, DEMUX, (<span class="literal">NULL</span>),</span><br><span class="line">     (<span class="string">"Non-compliant stream: sampling field missing. Frames my appear incorrect"</span>));</span><br></pre></td></tr></table></figure>
<h2 id="3-3-编译">3.3 编译</h2>
<p>和前面一样，流程是一样的：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">export PKG_CONFIG_LIBDIR=/media/guwen/workspace/project/gstreamer/out/lib/pkgconfig</span><br><span class="line">mkdir build</span><br><span class="line">cd build</span><br><span class="line">meson .. --cross-file ../qnx_arm.txt</span><br><span class="line">ninja</span><br><span class="line">ninja install</span><br></pre></td></tr></table></figure>
<h1>四、编译plugin bad库</h1>
<p>​         qnx_arm.txt这个cross file的内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">[host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line">pkgconfig  = 'pkg-config'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0','-lgstrtp-1.0', '-lffi']</span><br><span class="line">cpp_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">cpp_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0','-lgstrtp-1.0', '-lffi']</span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<p>meson.build 文件修改：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">default_options : [ 'warning_level=1',</span><br><span class="line">                    'buildtype=release' ]) #修改编译类型为release</span><br></pre></td></tr></table></figure>
<h2 id="4-1-修改编译错误">4.1 修改编译错误</h2>
<p>​        和plugin good一样，配置完成之后，编译会有错误需要修正。</p>
<ul>
<li>修改文件gst/timecode/gstavwait.c</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始版本 1128行 */</span></span><br><span class="line">GST_ELEMENT_ERROR (self, CORE, FAILED,</span><br><span class="line">       (<span class="string">"Failed to clip audio: it should have ended before the current segment"</span>),</span><br><span class="line">        <span class="literal">NULL</span>);</span><br><span class="line"><span class="comment">/////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line">GST_ELEMENT_ERROR (self, CORE, FAILED,</span><br><span class="line">       (<span class="string">"Failed to clip audio: it should have ended before the current segment"</span>),</span><br><span class="line">        (<span class="literal">NULL</span>));</span><br></pre></td></tr></table></figure>
<ul>
<li>修改文件 gst/videoparsers/gstjpeg2000parse.c</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始版本 354行 */</span></span><br><span class="line"><span class="keyword">if</span> (j2c_box_id_offset == <span class="number">-1</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Missing contiguous code stream box for j2c stream"</span>));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (j2c_box_id_offset == <span class="number">-1</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Missing contiguous code stream box for j2c stream"</span>));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 383行 */</span></span><br><span class="line"><span class="keyword">if</span> (j2c_box_id_offset + GST_JPEG2000_JP2_SIZE_OF_BOX_ID != magic_offset) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Corrupt contiguous code stream box for j2c stream"</span>));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (j2c_box_id_offset + GST_JPEG2000_JP2_SIZE_OF_BOX_ID != magic_offset) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Corrupt contiguous code stream box for j2c stream"</span>));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 421行 */</span></span><br><span class="line"><span class="keyword">if</span> ((profile &gt; GST_JPEG2000_PARSE_PROFILE_CINEMA_LTS)</span><br><span class="line">    &amp;&amp; !gst_jpeg2000_parse_is_broadcast (profile)</span><br><span class="line">    &amp;&amp; !gst_jpeg2000_parse_is_imf (profile)) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Unrecognized JPEG 2000 profile %d"</span>, profile));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> ((profile &gt; GST_JPEG2000_PARSE_PROFILE_CINEMA_LTS)</span><br><span class="line">    &amp;&amp; !gst_jpeg2000_parse_is_broadcast (profile)</span><br><span class="line">    &amp;&amp; !gst_jpeg2000_parse_is_imf (profile)) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Unrecognized JPEG 2000 profile %d"</span>, profile));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 434行 */</span></span><br><span class="line"><span class="keyword">if</span> (sub_level &gt; <span class="number">9</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Sub level %d is invalid"</span>, sub_level));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (sub_level &gt; <span class="number">9</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Sub level %d is invalid"</span>, sub_level));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 441行 */</span></span><br><span class="line"><span class="keyword">if</span> (validate_main_level &amp;&amp; main_level &gt; <span class="number">11</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Main level %d is invalid"</span>, main_level));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (validate_main_level &amp;&amp; main_level &gt; <span class="number">11</span>) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Main level %d is invalid"</span>, main_level));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/** 原始版本 464行 */</span></span><br><span class="line"></span><br><span class="line"><span class="comment">/* sanity check on image dimensions */</span></span><br><span class="line"><span class="keyword">if</span> (x1 &lt; x0 || y1 &lt; y0) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Nonsensical image dimensions %d,%d,%d,%d"</span>, x0, y0, x1, y1));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (x1 &lt; x0 || y1 &lt; y0) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Nonsensical image dimensions %d,%d,%d,%d"</span>, x0, y0, x1, y1));</span><br><span class="line">  ret = GST_FLOW_ERROR;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 原始版本 484行 */</span></span><br><span class="line"><span class="keyword">if</span> (numcomps == <span class="number">0</span> || numcomps &gt; GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, <span class="literal">NULL</span>,</span><br><span class="line">      (<span class="string">"Unsupported number of components %d"</span>, numcomps));</span><br><span class="line">  ret = GST_FLOW_NOT_NEGOTIATED;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改之后的版本 */</span>  </span><br><span class="line"><span class="keyword">if</span> (numcomps == <span class="number">0</span> || numcomps &gt; GST_JPEG2000_PARSE_MAX_SUPPORTED_COMPONENTS) &#123;</span><br><span class="line">  GST_ELEMENT_ERROR (jpeg2000parse, STREAM, DECODE, (<span class="literal">NULL</span>),</span><br><span class="line">      (<span class="string">"Unsupported number of components %d"</span>, numcomps));</span><br><span class="line">  ret = GST_FLOW_NOT_NEGOTIATED;</span><br><span class="line">  <span class="keyword">goto</span> beach;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="4-2-编译-fdk-aac-库">4.2 编译 fdk-aac 库</h2>
<p>​          不知道怎么回事，gstreamer的libav插件好多decoder都不能正常使用，这里我验证用的mkv文件里面音频是aac格式的，结果用libav就匹配不了， 因此只能使用开源的fdk-acc库，首先是配置的脚本文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./configure --prefix=/media/guwen/workspace/project/gstreamer/out --host=arm-unknown-nto-qnx6.6.0eabi --disable-static</span><br></pre></td></tr></table></figure>
<p>​           然后再进行编译安装</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">make -j4</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h2 id="4-3-编译">4.3 编译</h2>
<p>和前面一样，其过程如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">export PKG_CONFIG_LIBDIR=/media/guwen/workspace/project/gstreamer/out/lib/pkgconfig</span><br><span class="line">mkdir build</span><br><span class="line">cd build</span><br><span class="line">meson .. --cross-file ../qnx_arm.txt</span><br><span class="line">ninja</span><br><span class="line">ninja install</span><br></pre></td></tr></table></figure>
<h1>五、编译gst-libav 库</h1>
<h2 id="5-1-编译FFmpeg">5.1 编译FFmpeg</h2>
<p>​       首先是交叉编译FFmpeg库，第一步，<a href="http://xn--shellmyconfig-tt3uv02ari7fq3f8u4e6nfw51c3rbi5rh86b350blth.sh" target="_blank" rel="noopener">编写进行配置用的shell脚本文件myconfig.sh</a>，其内容如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">./configure --prefix=/media/guwen/workspace/project/gstreamer/out \</span><br><span class="line">        --cross-prefix=arm-unknown-nto-qnx6.6.0eabi- \</span><br><span class="line">        --enable-cross-compile \</span><br><span class="line">        --pkg-config=pkg-config \</span><br><span class="line">        --target-os=qnx \</span><br><span class="line">        --cc=arm-unknown-nto-qnx6.6.0eabi-gcc \</span><br><span class="line">        --arch=arm \</span><br><span class="line">        --enable-shared \</span><br><span class="line">        --disable-static \</span><br><span class="line">        --enable-gpl \</span><br><span class="line">        --enable-nonfree \</span><br><span class="line">        --disable-armv5te \</span><br><span class="line">        --disable-armv6 \</span><br><span class="line">        --disable-armv6t2 \</span><br><span class="line">        --disable-debug \</span><br><span class="line">        --enable-neon \</span><br><span class="line">        --extra-cflags="-std=gnu99 -fPIC" \</span><br><span class="line">        --disable-programs \</span><br><span class="line">        --disable-encoders \</span><br><span class="line">        --disable-devices \</span><br><span class="line">        --disable-muxers \</span><br><span class="line">        --disable-decoders \</span><br><span class="line">        --disable-demuxers \</span><br><span class="line">        --disable-avdevice \</span><br><span class="line">        --disable-bsfs \</span><br><span class="line">        --disable-filters \</span><br><span class="line">        --disable-doc \</span><br><span class="line">        --enable-decoder=h264 \</span><br><span class="line">        --enable-decoder=aac \</span><br><span class="line">        --enable-decoder=ac3 \</span><br><span class="line">        --enable-demuxer=mov \</span><br><span class="line">        --enable-demuxer=mp3 \</span><br><span class="line">        --enable-demuxer=matroska</span><br></pre></td></tr></table></figure>
<p>这里只enable了 h264 aac ac3 ， mov， mp3， matroska 等几个解码器和容器，这样既可以加快编译速度，也可以减少生成lib的大小。</p>
<ul>
<li>修改编译错误，文件libavformat/sctp.c</li>
</ul>
<p>​         这个文件的错误主要是因为CMSG_SPACE这个宏来计算recvmsg和sendmsg的buffer size， 其错误原因，将这个计算出来的size，作为一个数组的size，但CMSG_SPACE这个宏的实现里面有一个是获取align大小的函数__cmsg_alignbytes，因此就会报这样的错误：</p>
<blockquote>
<p>libavformat/sctp.c: In function ‘ff_sctp_recvmsg’:<br>
libavformat/sctp.c:80:17: error: variable length array ‘incmsg’ is used [-Werror=vla]<br>
libavformat/sctp.c: In function ‘ff_sctp_send’:<br>
libavformat/sctp.c:131:22: error: variable length array ‘outcmsg’ is used [-Werror=vla]</p>
</blockquote>
<p>​           因此这里需要自己实现CMSG_SPACE这个宏，在qnx的toolchain中，其定义如下：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * Alignment requirement for CMSG struct manipulation.</span></span><br><span class="line"><span class="comment"> * This basically behaves the same as ALIGN() ARCH/include/param.h.</span></span><br><span class="line"><span class="comment"> * We declare it separately for two reasons:</span></span><br><span class="line"><span class="comment"> * (1) avoid dependency between machine/param.h, and (2) to sync with kernel's</span></span><br><span class="line"><span class="comment"> * idea of ALIGNBYTES at runtime.</span></span><br><span class="line"><span class="comment"> * without (2), we can't guarantee binary compatibility in case of future</span></span><br><span class="line"><span class="comment"> * changes in ALIGNBYTES.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> __CMSG_ALIGN(n)	(((n) + __cmsg_alignbytes()) &amp; ~__cmsg_alignbytes())</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> CMSG_SPACE(l)	(__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(l))</span></span><br></pre></td></tr></table></figure>
<p>​            出现错误的原因就是因为这里的__cmsg_alignbytes是一个函数，其作用是获取cmsg是按几个字节对齐的，经过测试，这个函数的返回值为7， 因此这里实现的的宏如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">/**为了预防冲突，将CMSG_SPACE 修改为  MY_CMSG_SPACE */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> __MY_CMSG_ALIGN(n)	(((n) + 7) &amp; ~7)</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MY_CMSG_SPACE(l)	(__MY_CMSG_ALIGN(sizeof(struct cmsghdr)) + __MY_CMSG_ALIGN(l))</span></span><br></pre></td></tr></table></figure>
<ul>
<li>修改运行错误，文件libavutil/mem.c</li>
</ul>
<p>​       变了了FFMpeg4.2.1之后，在运行的时候发现在libavutil/eval.c文件的av_expr_parse_and_eval这个函数里面调用av_expr_free这个函数时，会在最后av_freep(&amp;e);这句的时候发生错误(并产生coredump)， 一开始我以为是发生了内存越界，但是通过在这段内存的前后都加上16字节的空余空间，在av_freep(&amp;e);这句之前打印是否存在内存越界，结果是，并没有发生内存越界，更奇妙的是，这样做之后也不会发生错误了。 在网上搜索了一下，发现qnx下的posix_memalign 和memalign这两个函数似乎有问题， 因此这里需要修改一下av_malloc函数的实现：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> *<span class="title">av_malloc</span><span class="params">(<span class="keyword">size_t</span> size)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">void</span> *ptr = <span class="literal">NULL</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/* let's disallow possibly ambiguous cases */</span></span><br><span class="line">  <span class="keyword">if</span> (size &gt; (max_alloc_size - <span class="number">32</span>))</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line"> <span class="meta">#<span class="meta-keyword">if</span> 0 <span class="comment">/** 注释掉原本的实现 */</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> HAVE_POSIX_MEMALIGN</span></span><br><span class="line">	<span class="keyword">if</span> (size) <span class="comment">//OS X on SDK 10.6 has a broken posix_memalign implementation</span></span><br><span class="line">    <span class="keyword">if</span> (posix_memalign(&amp;ptr, ALIGN, size))</span><br><span class="line">        ptr = <span class="literal">NULL</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">elif</span> HAVE_ALIGNED_MALLOC</span></span><br><span class="line">    ptr = _aligned_malloc(size, ALIGN);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">elif</span> HAVE_MEMALIGN</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">ifndef</span> __DJGPP__</span></span><br><span class="line">     ptr = memalign(ALIGN, size);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">     ptr = memalign(size, ALIGN);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    <span class="comment">/* Why 64?</span></span><br><span class="line"><span class="comment">     * Indeed, we should align it:</span></span><br><span class="line"><span class="comment">     *   on  4 for 386</span></span><br><span class="line"><span class="comment">     *   on 16 for 486</span></span><br><span class="line"><span class="comment">     *   on 32 for 586, PPro - K6-III</span></span><br><span class="line"><span class="comment">     *   on 64 for K7 (maybe for P3 too).</span></span><br><span class="line"><span class="comment">     * Because L1 and L2 caches are aligned on those values.</span></span><br><span class="line"><span class="comment">     * But I don't want to code such logic here!</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="comment">/* Why 32?</span></span><br><span class="line"><span class="comment">     * For AVX ASM. SSE / NEON needs only 16.</span></span><br><span class="line"><span class="comment">     * Why not larger? Because I did not see a difference in benchmarks ...</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="comment">/* benchmarks with P3</span></span><br><span class="line"><span class="comment">     * memalign(64) + 1          3071, 3051, 3032</span></span><br><span class="line"><span class="comment">     * memalign(64) + 2          3051, 3032, 3041</span></span><br><span class="line"><span class="comment">     * memalign(64) + 4          2911, 2896, 2915</span></span><br><span class="line"><span class="comment">     * memalign(64) + 8          2545, 2554, 2550</span></span><br><span class="line"><span class="comment">     * memalign(64) + 16         2543, 2572, 2563</span></span><br><span class="line"><span class="comment">     * memalign(64) + 32         2546, 2545, 2571</span></span><br><span class="line"><span class="comment">     * memalign(64) + 64         2570, 2533, 2558</span></span><br><span class="line"><span class="comment">     *</span></span><br><span class="line"><span class="comment">     * BTW, malloc seems to do 8-byte alignment by default here.</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span></span></span><br><span class="line">    ptr = <span class="built_in">malloc</span>(size);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">else</span> <span class="comment">/**使用普通的malloc来替代posix_memalign 或 memalign函数 */</span></span></span><br><span class="line">    ptr = <span class="built_in">malloc</span>(size);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span> <span class="comment">/** */</span></span></span><br><span class="line">    </span><br><span class="line">    <span class="keyword">if</span>(!ptr &amp;&amp; !size) &#123;</span><br><span class="line">        size = <span class="number">1</span>;</span><br><span class="line">        ptr= av_malloc(<span class="number">1</span>);</span><br><span class="line">    &#125;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">if</span> CONFIG_MEMORY_POISONING</span></span><br><span class="line">    <span class="keyword">if</span> (ptr)</span><br><span class="line">        <span class="built_in">memset</span>(ptr, FF_MEMORY_POISON, size);</span><br><span class="line"><span class="meta">#<span class="meta-keyword">endif</span></span></span><br><span class="line">    <span class="keyword">return</span> ptr;</span><br></pre></td></tr></table></figure>
<ul>
<li>
<p>编译过程</p>
 <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">make</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="5-2-准备gst-libav库编译脚本">5.2 准备gst-libav库编译脚本</h2>
<ul>
<li>编写meson的cross file 文件qnx_arm.txt</li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">[host_machine]</span><br><span class="line">system = 'qnx'</span><br><span class="line">cpu_family = 'arm'</span><br><span class="line">cpu = 'armv7'</span><br><span class="line">endian = 'little'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[binaries]</span><br><span class="line">c = 'arm-unknown-nto-qnx6.6.0eabi-gcc'</span><br><span class="line">cpp = 'arm-unknown-nto-qnx6.6.0eabi-g++'</span><br><span class="line">ar = 'arm-unknown-nto-qnx6.6.0eabi-ar'</span><br><span class="line">strip = 'arm-unknown-nto-qnx6.6.0eabi-strip'</span><br><span class="line">pkgconfig  = 'pkg-config'</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">[properties]</span><br><span class="line">c_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">c_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lffi']</span><br><span class="line">cpp_args = ['-D_QNX_SOURCE=1']</span><br><span class="line">cpp_link_args = ['-lsocket', '-L/media/guwen/workspace/project/gstreamer/out/lib', '-lgobject-2.0', '-lgio-2.0', '-lgmodule-2.0', '-lffi']</span><br><span class="line"></span><br><span class="line">[paths]</span><br><span class="line">prefix = '/media/guwen/workspace/project/gstreamer/out'</span><br></pre></td></tr></table></figure>
<ul>
<li>
<p>修改meson.build文件</p>
<pre><code> <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">default_options : [ 'warning_level=1',</span><br><span class="line">                    'buildtype=release' ]) #编译 release版本</span><br></pre></td></tr></table></figure>
</code></pre>
</li>
<li>
<p>新增mp3 demuxer支持</p>
</li>
</ul>
<p>​        我完成了所有编译移植之后，原本想那个常见的音乐格式mp3文件进行测试，但发现，却没有找到支持mp3 格式的demuxer插件或元件。因此需要在gst-libav目录里面把对于mp3格式的支持放开。</p>
<ul>
<li>新增mkv demuxer支持，</li>
</ul>
<p>​         同样，在进行视频播放测试的时候，准备使用mkv格式的视频进行播放，发现libgstmatroska.so这个插件，并不能支持我用于测试的常见的mkv文件，不知道为什么，于是就准备使用libav这个插件来进行支持。</p>
<p>​        最终对gstavdemux.c文件中的的 gboolean gst_ffmpegdemux_register (GstPlugin * plugin)函数的修改内容如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">   <span class="comment">/* Don't use the typefind functions of formats for which we already have</span></span><br><span class="line"><span class="comment">     * better typefind functions */</span></span><br><span class="line">    <span class="keyword">if</span> (!<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"mov,mp4,m4a,3gp,3g2,mj2"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"ass"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"avi"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"asf"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"mpegvideo"</span>) ||</span><br><span class="line">        <span class="comment">/*!strcmp (in_plugin-&gt;name, "mp3") || </span></span><br><span class="line"><span class="comment">        !strcmp (in_plugin-&gt;name, "matroska") ||</span></span><br><span class="line"><span class="comment">        !strcmp (in_plugin-&gt;name, "matroska_webm") ||</span></span><br><span class="line"><span class="comment">        !strcmp (in_plugin-&gt;name, "matroska,webm") ||*/</span> <span class="comment">//修改部分，放开mp3和mkv容器的限制</span></span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"mpeg"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"wav"</span>) ||</span><br><span class="line">        </span><br><span class="line"><span class="comment">////////////////////////////////////////////////////////////////////////////////////        </span></span><br><span class="line">        </span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"brstm"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"bfstm"</span>) ||</span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"gif"</span>) ||</span><br><span class="line">		!<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"mp3"</span>) || <span class="comment">/**新增mp3容器支持 */</span></span><br><span class="line">		!<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"matroska"</span>) || <span class="comment">/**新增mkv容器支持 */</span></span><br><span class="line">		!<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"matroska_webm"</span>) || <span class="comment">/**新增mkv容器支持 */</span></span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"matroska,webm"</span>) || <span class="comment">/**新增mkv容器支持 */</span></span><br><span class="line">        !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"dsf"</span>) || !<span class="built_in">strcmp</span> (in_plugin-&gt;name, <span class="string">"iff"</span>))</span><br></pre></td></tr></table></figure>
<ul>
<li>另外，修正一个gstavdemux.c文件中的错误</li>
</ul>
<p>​        准确的说应该是完善， 在gstavdemux.c文件中gst_ffmpegdemux_type_find函数中需要通过plugin name作为fromat名称，来生成对应的sink pad的 caps信息， 但是在使用libav中的mkv容器时， 其形式为 “matroska,webm”， 这样gst_ffmpeg_formatid_to_caps中生成的caps就会将这个名称看出两个字段 “matroska” 和“webm&quot;， 也为了避免这个问题，需要像其他地方一样使用 g_strdelimit来将 ‘,’ 之类的符号替换为’_’。 其具体修改如下所示：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/** 原始代码 */</span></span><br><span class="line">      sinkcaps = gst_ffmpeg_formatid_to_caps (in_plugin-&gt;name);</span><br><span class="line"></span><br><span class="line">      GST_LOG (<span class="string">"libav typefinder '%s' suggests %"</span> GST_PTR_FORMAT <span class="string">", p=%u%%"</span>,</span><br><span class="line">          in_plugin-&gt;name, sinkcaps, res);</span><br><span class="line"></span><br><span class="line">      gst_type_find_suggest (tf, res, sinkcaps);</span><br><span class="line">      gst_caps_unref (sinkcaps);</span><br><span class="line"></span><br><span class="line"><span class="comment">///////////////////////////////////////////////////////////////////////////////</span></span><br><span class="line"><span class="comment">/** 修改后的代码 */</span></span><br><span class="line">      gchar* format_name = g_strdup(in_plugin-&gt;name); <span class="comment">/** dup一份plugin的名称 */</span></span><br><span class="line">      g_strdelimit (format_name, <span class="string">".,|-&lt;&gt; "</span>, <span class="string">'_'</span>); <span class="comment">/** 将字符串中的 ',' 替换为'_'  */</span></span><br><span class="line"></span><br><span class="line">      sinkcaps = gst_ffmpeg_formatid_to_caps (format_name);  <span class="comment">/** 生成sink caps */</span></span><br><span class="line"></span><br><span class="line">      GST_LOG (<span class="string">"libav typefinder '%s' suggests %"</span> GST_PTR_FORMAT <span class="string">", p=%u%%"</span>,</span><br><span class="line">          in_plugin-&gt;name, sinkcaps, res);</span><br><span class="line"></span><br><span class="line">      gst_type_find_suggest (tf, res, sinkcaps);</span><br><span class="line">      gst_caps_unref (sinkcaps);</span><br><span class="line">      g_free(format_name);  <span class="comment">/** 使用完之后，释放掉dup来的字符串 */</span></span><br></pre></td></tr></table></figure>
<h2 id="5-3-编译">5.3 编译</h2>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">export PKG_CONFIG_LIBDIR=/media/guwen/workspace/project/gstreamer/out/lib/pkgconfig</span><br><span class="line">mkdir build</span><br><span class="line">cd build</span><br><span class="line">meson .. --cross-file ../qnx_arm.txt</span><br><span class="line">ninja</span><br><span class="line">ninja install</span><br></pre></td></tr></table></figure>
<h1>六、总结</h1>
<p>其实编译出来的不少插件，这里都是没有用到的，如果要精细编译的话，就需要针对这些插件库进行细致的配置，明确的指定enable项。</p>
<p>另外 对于meson编译方式，其实原则上不应该去修改 meson.build文件， 应该视同meson -Dxxx=xxx的方式， 这里其实可以使用和configure编译方式一样的做法， 将运行meson 命令相关的内容写到一个shell脚本文件里面去。这样每个项目就只需要新增qnx_arm.txt 和一个类似myconfig.sh的shell脚本。</p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/posts/28659.html">gstreamer移植qnx(四)：编译gstreamer插件</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">古 文</a></p>
        <p><span>发布时间:</span>2020-02-20, 15:10:12</p>
        <p><span>最后更新:</span>2020-02-20, 21:01:09</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/posts/28659.html" title="gstreamer移植qnx(四)：编译gstreamer插件">http://xuanwolanxue.gitee.io/posts/28659.html</a>
            <span class="copy-path" data-clipboard-text="原文: http://xuanwolanxue.gitee.io/posts/28659.html　　作者: 古 文" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target="_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/posts/50488.html">
                    gstreamer移植qnx(二)：移植glib2.6.3
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/posts/30680.html">
                    gstreamer移植qnx(五)：编写audio sink和video sink插件
                </a>
            </div>
        
    </nav>

  
  
    
    <div style="padding: 0; margin: 20px auto; width: 90%; text-align: center;">
      <br>
      <div>有钱的捧个钱场，1元2元1毛2毛都行，您的支持将鼓励我继续创作！</div>
      <br>
      <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
        <div class="btn btn-pay">打赏支持</div>
      </button>
      <br>
      <br>
      <div id="QR" style="display: none;">
        
          <div id="wechat" style="display: inline-block;">
            <img id="wechat_qr" src="/img/wechat-reward-qr.png" alt="古 文 WeChat Pay">
            <p>微信打赏</p>
          </div>
        
        
          <div id="alipay" style="display: inline-block">
            <img id="alipay_qr" src="/img/alipay-reward-qr.png" alt="古 文 Alipay">
            <p>支付宝打赏</p>
          </div>
        
        <br>
        <br>
      </div>
    </div>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">1.</span> <span class="toc-text">一、简介</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">2.</span> <span class="toc-text">二、 编译plugin base 库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">3.</span> <span class="toc-text">三、编译plugin good 库</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">4.</span> <span class="toc-text">3.1 编译mpg123</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#3-2-修改编译错误"><span class="toc-number">4.1.</span> <span class="toc-text">3.2 修改编译错误</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-3-编译"><span class="toc-number">4.2.</span> <span class="toc-text">3.3 编译</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">5.</span> <span class="toc-text">四、编译plugin bad库</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#4-1-修改编译错误"><span class="toc-number">5.1.</span> <span class="toc-text">4.1 修改编译错误</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-2-编译-fdk-aac-库"><span class="toc-number">5.2.</span> <span class="toc-text">4.2 编译 fdk-aac 库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-3-编译"><span class="toc-number">5.3.</span> <span class="toc-text">4.3 编译</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">6.</span> <span class="toc-text">五、编译gst-libav 库</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#5-1-编译FFmpeg"><span class="toc-number">6.1.</span> <span class="toc-text">5.1 编译FFmpeg</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-2-准备gst-libav库编译脚本"><span class="toc-number">6.2.</span> <span class="toc-text">5.2 准备gst-libav库编译脚本</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-3-编译"><span class="toc-number">6.3.</span> <span class="toc-text">5.3 编译</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#undefined"><span class="toc-number">7.</span> <span class="toc-text">六、总结</span></a></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-6 i,
        .toc-level-6 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录" title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"gstreamer移植qnx(四)：编译gstreamer插件　| 同好斋　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
		<section id="comments" style="margin: 2em; padding: 2em; background: rgba(255, 255, 255, 0.5)">
    <div id="vcomment" class="comment"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@1.2.0-beta1/dist/Valine.min.js"></script>
    <script>
      new Valine({
        el: '#vcomment',
        notify: 'true',
        verify: 'true',
        app_id: "jGY8jU1Gd1LKJ1meqfpUrpfp-gzGzoHsz",
        app_key: "LnXY7e40Vnir0zsqU62K1MNA",
        placeholder: "评论",
        avatar: "mp"
      });
    </script>
</section>
	
	




    <div class="scroll" id="post-nav-button">
        
            <a href="/posts/50488.html" title="上一篇: gstreamer移植qnx(二)：移植glib2.6.3">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/posts/30680.html" title="下一篇: gstreamer移植qnx(五)：编写audio sink和video sink插件">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/64143.html">repo安装与简单使用</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4046.html">gstreamer移植qnx(三)：libgstreamer 移植</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/50488.html">gstreamer移植qnx(二)：移植glib2.6.3</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/28659.html">gstreamer移植qnx(四)：编译gstreamer插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/30680.html">gstreamer移植qnx(五)：编写audio sink和video sink插件</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/4138.html">gstreamer移植qnx(一)：概览篇</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/3250.html">c印记</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/56107.html">因为爱情</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2018-2020 古 文
                <br><br>
                <br>同好斋小网站<br>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_uv">
                      您是第 <span id="busuanzi_value_site_uv"></span> 位小伙伴
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        本站总访问量 <span id="busuanzi_value_site_pv"></span> 次
                    </span>
                
                <span>| </span>
                <span class="post-count">  已经写了 14.2k 字啦</span>
            </div>
        
        <br>
        <span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
        <script>
            var now = new Date(); 
            function createtime(){ var grt= new Date("12/19/2018 12:49:00");//此处修改你的建站时间或者网站上线时间 
            now.setTime(now.getTime()+250); 
            days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); 
            hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); 
            if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); 
            mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} 
            seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); 
            snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} 
            document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 "; 
            document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒"; } 
            setInterval("createtime()",250);
        </script>
        <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        $("a[target=_blank]").removeAttr("target");
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>




	<script type="text/javascript" src="/resources/love.js"></script>
	<script type="text/javascript" src="/resources/float.js"></script>
	<script type="text/javascript" src="/resources/typewriter.js"></script>
	<script type="text/javascript" color="0,104,183" opacity="1" zindex="-1" count="50" src="/resources/particle.js"></script>


  </div>
<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/wanko.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-100},"mobile":{"show":false},"react":{"opacityDefault":0.5,"opacityOnHover":0.2},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>